#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Termstructures/Volatility/Capfloor/CapFloorTermVolatilityStructure.h>
#pragma unmanaged 
#include <ql\termstructures\volatility\capfloor\capfloortermvolsurface.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Times;
using namespace Cephei::QL::Math;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Termstructures { namespace Volatility { namespace Capfloor {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of ICapFloorTermVolSurface
	public ref class CCapFloorTermVolSurface : 
            public CCapFloorTermVolatilityStructure,
            public Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface
	{
	protected: 
		boost::shared_ptr<QuantLib::CapFloorTermVolSurface>* _ppCapFloorTermVolSurface;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CapFloorTermVolSurface>* _phCapFloorTermVolSurface;
#endif
		Object^ _CapFloorTermVolSurfaceOwner;     // reference to object that manages the storage for this object
	internal:
		CCapFloorTermVolSurface (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::QL::Math::IMatrix^ volatilities, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
		CCapFloorTermVolSurface (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::QL::Math::IMatrix^ volatilities, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
		CCapFloorTermVolSurface (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::IMatrix<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
		CCapFloorTermVolSurface (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::IMatrix<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
        CCapFloorTermVolSurface (boost::shared_ptr<QuantLib::CapFloorTermVolSurface>& childNative, Object^ owner);
        CCapFloorTermVolSurface (QuantLib::CapFloorTermVolSurface& childNative, Object^ owner);
        CCapFloorTermVolSurface (CCapFloorTermVolSurface^ copy);
        CCapFloorTermVolSurface (System::Type^ t);
#ifdef STRUCT
        CCapFloorTermVolSurface (QuantLib::CapFloorTermVolSurface childNative);
#endif       
#ifdef HANDLE
		CCapFloorTermVolSurface (QuantLib::Handle<QuantLib::CapFloorTermVolSurface>& childNative, Object^ owner);
		CCapFloorTermVolSurface (QuantLib::Handle<QuantLib::CapFloorTermVolSurface> childNative);
#endif
		virtual ~CCapFloorTermVolSurface ();
		!CCapFloorTermVolSurface ();

	internal:
		QuantLib::CapFloorTermVolSurface& GetReference ();
		boost::shared_ptr<QuantLib::CapFloorTermVolSurface>& GetShared ();
		QuantLib::CapFloorTermVolSurface* GetPointer ();
        void SetCapFloorTermVolSurface (boost::shared_ptr<QuantLib::CapFloorTermVolSurface> native)
        {
            if (_ppCapFloorTermVolSurface != NULL)
                delete _ppCapFloorTermVolSurface;
            _ppCapFloorTermVolSurface = new boost::shared_ptr<QuantLib::CapFloorTermVolSurface> (native);
            SetCapFloorTermVolatilityStructure (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolSurface));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::CapFloorTermVolSurface>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
        property DateTime MaxDate 
        {
		    virtual DateTime get () ;
        }
        property Double MaxStrike 
        {
		    virtual Double get () ;
        }
        property Double MinStrike 
        {
		    virtual Double get () ;
        }
        property Cephei::IVector<DateTime>^ OptionDates 
        {
		    virtual Cephei::IVector<DateTime>^ get () ;
        }
        property Cephei::IVector<Cephei::QL::Times::IPeriod^>^ OptionTenors 
        {
		    virtual Cephei::IVector<Cephei::QL::Times::IPeriod^>^ get () ;
        }
        property Cephei::IVector<Double>^ OptionTimes 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
        property Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^ PerformCalculations 
        {
		    virtual Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^ get () ;
        }
        property Cephei::IVector<Double>^ Strikes 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
        property Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^ Update 
        {
		    virtual Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^ get () ;
        }
        property Double M1931_MaxStrike 
        {
            virtual Double get () = Cephei::QL::Termstructures::IVolatilityTermStructure::MaxStrike::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^)this)->MaxStrike;
            }
        }
        property Double M1931_MinStrike 
        {
            virtual Double get () = Cephei::QL::Termstructures::IVolatilityTermStructure::MinStrike::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^)this)->MinStrike;
            }
        }
        property DateTime M1931_MaxDate 
        {
            virtual DateTime get () = Cephei::QL::ITermStructure::MaxDate::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^)this)->MaxDate;
            }
        }
        property Cephei::QL::ITermStructure^ M1931_Update 
        {
            virtual Cephei::QL::ITermStructure^ get () = Cephei::QL::ITermStructure::Update::get
            {
                return ((Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolSurface^)this)->Update;
            }
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CCapFloorTermVolSurface_Factory : public System::MarshalByRefObject,  public ICapFloorTermVolSurface_Factory
	{
	public:
        virtual ICapFloorTermVolSurface^ Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::QL::Math::IMatrix^ volatilities, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
        virtual ICapFloorTermVolSurface^ Create (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::QL::Math::IMatrix^ volatilities, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
        virtual ICapFloorTermVolSurface^ Create (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::IMatrix<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
        virtual ICapFloorTermVolSurface^ Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ strikes, Cephei::IMatrix<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc);
    };
   
/*Cephei*/ } /*QL*/ } /*Termstructures*/ } /*Volatility*/ } /*Capfloor */}
